import React, { Component } from 'react';
import { connect } from 'dva';
import { Spin, Icon } from 'antd';
import PropTypes from 'prop-types';
import styles from './echartStyle.less';

class DoubleLineChart extends Component {
  static propTypes = {
    // secu_code: PropTypes.string.isRequired,
    // type: PropTypes.string,
    chartID: PropTypes.string,
  };

  static defaultProps = {
    chartID: '',
  };

  componentDidMount() {
    const { dispatch, chartID } = this.props;

    dispatch({
      type: 'home/getHmld',
      chartID: chartID,
      payload: {
        stock_code: JSON.parse(sessionStorage.getItem('LOGIN_INFO')).stock_code,
      },
    });
  }

  render() {
    const { chartID, loading } = this.props;
    return (
      <Spin tip="数据读取中..." spinning={loading}>
        <div id={chartID} className={styles.lineContainer} />
      </Spin>
    );
  }
}

const mapStateToProps = state => ({
  loading: state.loading.effects['home/getHmld'],
});
export default connect(mapStateToProps)(DoubleLineChart);
